package com.xydtech.system.service.impl;

import com.xydtech.common.core.text.Convert;
import com.xydtech.common.utils.DateUtils;
import com.xydtech.system.domain.SysLoanCalculator;
import com.xydtech.system.mapper.SysLoanCalculatorMapper;
import com.xydtech.system.mapper.SysLoanConfigurationMapper;
import com.xydtech.system.service.ISysLoanCalculatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <dd>描述: ~ 贷款计算器信息Service业务层处理</dd>
 * <dd>创建时间：  10:09 2024/1/20</dd>
 * <dd>创建人： yuzhiguo</dd>
 * <dt>版本历史: </dt>
 * Date         Author         Version     Description
 * ------------------------------------------------------------------
 * 2024/1/20     yuzhiguo         1.0        1.0 Version
 */
@Service
public class SysLoanCalculatorServiceImpl implements ISysLoanCalculatorService {

    @Autowired
    private SysLoanCalculatorMapper sysLoanCalculatorMapper;

    @Autowired
    private SysLoanConfigurationMapper sysLoanConfigurationMapper;

    /**
     * 查询贷款计算器信息
     *
     * @param id 贷款计算器信息主键
     * @return 贷款计算器信息
     */
    @Override
    public SysLoanCalculator selectSysLoanCalculatorById(Long id)
    {
        return sysLoanCalculatorMapper.selectSysLoanCalculatorById(id);
    }

    /**
     * 查询贷款计算器信息列表
     *
     * @param sysLoanCalculator 贷款计算器信息
     * @return 贷款计算器信息
     */
    @Override
    public List<SysLoanCalculator> selectSysLoanCalculatorList(SysLoanCalculator sysLoanCalculator)
    {
        return sysLoanCalculatorMapper.selectSysLoanCalculatorList(sysLoanCalculator);
    }

    /**
     * 新增贷款计算器信息
     *
     * @param sysLoanCalculator 贷款计算器信息
     * @return 结果
     */
    @Override
    public int insertSysLoanCalculator(SysLoanCalculator sysLoanCalculator)
    {
        sysLoanCalculator.setCreateTime(DateUtils.getNowDate());
        Long id = sysLoanCalculatorMapper.insertSysLoanCalculator(sysLoanCalculator)> 0 ? sysLoanCalculator.getId() : null;
        return sysLoanConfigurationMapper.insertLoanId(id);
    }

    /**
     * 修改贷款计算器信息
     *
     * @param sysLoanCalculator 贷款计算器信息
     * @return 结果
     */
    @Override
    public int updateSysLoanCalculator(SysLoanCalculator sysLoanCalculator)
    {
        sysLoanCalculator.setUpdateTime(DateUtils.getNowDate());
        return sysLoanCalculatorMapper.updateSysLoanCalculator(sysLoanCalculator);
    }

    /**
     * 批量删除贷款计算器信息
     *
     * @param ids 需要删除的贷款计算器信息主键
     * @return 结果
     */
    @Override
    public int deleteSysLoanCalculatorByIds(String ids)
    {
        return sysLoanCalculatorMapper.deleteSysLoanCalculatorByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除贷款计算器信息信息
     *
     * @param id 贷款计算器信息主键
     * @return 结果
     */
    @Override
    public int deleteSysLoanCalculatorById(Long id)
    {
        return sysLoanCalculatorMapper.deleteSysLoanCalculatorById(id);
    }

}
